package sort.test4_7;

public class InsertSort {

    public  int[]  insertSort(int[] nums){
        if (nums.length==0){
            return null;
        }
        for (int i = 1; i < nums.length; i++) {
            for (int j = i-1; j >=0; j--) {
                if (nums[i]<nums[j]){
                    int temp=nums[i];
                    nums[i]=nums[j];
                    nums[j]=temp;
                }
            }
        }
        return nums;
    }

    public static void main(String[] args) {
       InsertSort insertSort = new InsertSort();
        int[]  nums={2,1,3,5,4,6};
        insertSort.insertSort(nums);
        for (int a:nums) {
            System.out.println(a);
        }
    }



}
